<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" isELIgnored="false"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%@ taglib uri="http://jsptags.com/tags/navigation/pager" prefix="pg" %>
<%@ taglib prefix="fmt"     uri="http://java.sun.com/jstl/fmt_rt" %>

<style>
#comments {text-align:center;border:1px solid #ddd; border-width:0 0 1px 1px;}

#comments th {background:#CCEEFF;}
#comments th,#comments td {height:22px; border:1px solid #ddd; border-width:1px 1px 0 0;}
</style>

<script type="text/javascript">
<!--
	function onSave(){
		  var errorMsg = "";
			if($("#comment").val().trim()==""){
				errorMsg = '<s:text name="dialog.message.tip.needContent"/>' ;
			}
			if(errorMsg != ""){
				showErrorTip(errorMsg);
				return false;
			}
			return true;
	}
	
	function editSa(saId){
			window.location.href = "./SaMgr_editSa.do?editSaId="+saId;
	}
	
//-->
</script>

<s:include value="./component/tip_box.jsp"></s:include>

<div  style="background-color:#F5F5F5;margin-top:1cm;">
	<s:form action="SACommentMgr_addComment" validate="false" onsubmit="return onSave()">
		<input name="pager.offset" type="hidden"  value="${pm.offset}">
		<input name="saComment.saId" type="hidden"  value="${saId}">
		<input name="saId" type="hidden"  value="${saId}">
		
		<div align="left">
			<s:actionmessage cssStyle="color:#0000FF;"/>
			<s:actionerror cssStyle="color:#F00;"/>
		</div>
		<table width="80%" height="60">
			<tr>
				<td align="left"  width="15%">
				    <s:textarea id="comment" name="saComment.comment" rows="4" cssStyle="width: 710px;font-family: Arial;"></s:textarea>
				</td>
			</tr>
			
			<tr>
				<td align="right" width="20%">
					<s:submit key="action.add" action="SACommentMgr_addComment" cssClass="btn"/>
					<input type="button" class="btn" value="<s:text name="action.return"/>" onclick="editSa('${saId}')">
				</td>
			</tr>
		</table>
	</s:form>
	
	<table width="100%" id="comments">
		<thead>
			<tr class="ui-widget-header">
				<th style="width: 10em;"><s:text name="sa.comment.createTime"/></th>
				<th style="width: 10em;"><s:text name="sa.comment.createBy"/></th>
				<th style="width: 30em;"><s:text name="sa.comment.content"/></th>
			</tr>
		</thead>
		<tbody>
			<s:include value="./component/result_empty.jsp"></s:include>
			<c:forEach var="each" items="${pm.datas}">
				<tr>
					<td><fmt:formatDate value="${each.createTime}" pattern="yyyy-MM-dd HH:mm"/></td>
					<td>${each.createBy.username}</td>
					<td>${each.comment}</td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
</div>

<div align="left">
   <pg:pager url="./SACommentMgr_search.do" items="${pm.total}" maxPageItems="${pm.maxPageItems}" export="currentPageNumber=pageNumber">  
			<pg:param name="saId"/>
			<pg:page export="firstItem, lastItem">
				<div class="resultInfo">
					Displaying results <strong><%= firstItem %>-<%= lastItem %></strong> of <strong>${pm.total}</strong> found
				</div>
			</pg:page>
			
			<div class="rnav">
				<span class="rnavLabel">Results:</span>&nbsp;
				<pg:prev export="pageUrl">
					<a href="<%= pageUrl %>" class="rnavLink">&#171;&nbsp;Prev</a>&nbsp;
				</pg:prev>
				<pg:pages export="pageUrl,pageNumber,firstItem,lastItem">
				    <% if (pageNumber == currentPageNumber) { %> 
				&nbsp;<span class="rnavCurr"><%= firstItem %>-<%= lastItem %></span>
				    <% } else { %>
				&nbsp;<a href="<%= pageUrl %>" class="rnavLink"><%= firstItem %>-<%= lastItem %></a>
				    <% } %>
				</pg:pages>
				<pg:next export="pageUrl">
					&nbsp;&nbsp;<a href="<%= pageUrl %>" class="rnavLink">Next&nbsp;&#187;</a>
				</pg:next>
			</div>
   </pg:pager>
</div>